import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SWFInfo } from "../../../../com/gengine/resource/info/SWFInfo";
import { ObjCreate } from "../common/ObjCreate";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { ScrollBarDirection } from "../../../../fl/controls/ScrollBarDirection";
import { CrossSpaEnterRender } from "./cell/CrossSpaEnterRender";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { DataProvider } from "../../../../fl/data/DataProvider";
type int = number;
//class CrossSpaEntranceWindow
    
    export  class CrossSpaEntranceWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(679, 460);
            titleHeight = 26;
            title = Language.getString(60710);
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SpaRefreshCrossSpaList));
            return;
        }

        protected /* override */ createChildren(): void
        {
            var bgskyCity: Object /* flash.display.Bitmap */;
            var onLoadedComplete: Function;
            var tipsTextFormat: Object /* flash.text.TextFormat */;
            var tfTips: Object /* flash.text.TextField */;

            var loc1;
            bgskyCity = null;
            onLoadedComplete = null;
            onLoadedComplete = (arg1: SWFInfo): void
            {
                bgskyCity.bitmapData = arg1.bitmapData;
                return;
            }
            super.createChildren();
            ObjCreate.createBg(18, 38, 643, 337, this);
            bgskyCity = new Object /* flash.display.Bitmap */();
            bgskyCity.x = 19;
            bgskyCity.y = 39;
            this.addChild(bgskyCity);
            LoaderManager.instance.load("peaceFieldBg.swf", onLoadedComplete);
            this._crossSpaTilelist = new GTileList();
            this._crossSpaTilelist.setSize(590, 246);
            this._crossSpaTilelist.columnWidth = 118;
            this._crossSpaTilelist.rowHeight = 123;
            this._crossSpaTilelist.direction = ScrollBarDirection.VERTICAL;
            this._crossSpaTilelist.horizontalGap = 0;
            this._crossSpaTilelist.verticalGap = 0;
            this._crossSpaTilelist.setStyle("skin", new Object /* flash.display.Bitmap */());
            this._crossSpaTilelist.setStyle("cellRenderer", CrossSpaEnterRender);
            this._crossSpaTilelist.x = 30;
            this._crossSpaTilelist.y = 60;
            this.addChild(this._crossSpaTilelist);
            this._pageSelecter = new PageSelecter();
            this._pageSelecter.mode = PageSelecter.CompleteMode;
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.onChange);
            ObjCreate.setObjAttri(this._pageSelecter, 278, 334, -1, -1, this);
            tipsTextFormat = new GTextFormat(FontUtil.songtiName, 12, 6350622);
            tipsTextFormat.leading = 5;
            tfTips = ObjCreate.createTextField("", 18, 380, 550, 78, this, tipsTextFormat);
            tfTips.multiline = true;
            tfTips.wordWrap = true;
            tfTips.mouseWheelEnabled = false;
            tfTips.htmlText = Language.getString(60711);
            return;
        }

        public updateList(arg1: Array<any>): void
        {
            this._crossSpas = arg1;
            this._pageSelecter.currentPage = 1;
            this._pageSelecter.maxPage = Math.ceil(this._crossSpas.length / this.PageSize);
            this.updateFieldsByPage();
            return;
        }

        /* internal  */onChange(arg1: Object /* flash.events.Event */): void
        {
            this.updateFieldsByPage();
            return;
        }

        /* internal  */updateFieldsByPage(): void
        {
            var loc1=(this._pageSelecter.currentPage - 1) * this.PageSize;
            var loc2=Math.min(loc1 + this.PageSize, this._crossSpas.length);
            var loc3=new Array<any>();
            var loc4=loc1;
            while (loc4 < loc2) 
            {
                loc3.push(this._crossSpas[loc4]);
                ++loc4;
            }
            this._crossSpaTilelist.dataProvider = new DataProvider(loc3);
            return;
        }

        /* internal */ /* var */_crossSpaTilelist: GTileList;

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */PageSize: int=10;

        /* internal */ /* var */_crossSpas: Array<any>;
    }
